//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

append scripts
  script(src="/js/p1/index.js")

block form_items
  .field.thirteen.wide
    .ui.buttons.right.floated
      if page_perms.new
        button#new.ui.green.left.icon.labeled.button(type="button"
          onclick="window.location = '/p1/new'") 新 增
          i.icon.plus
      else
        button#new.ui.green.left.icon.labeled.button.disabled(type="button")
          i.icon.ban(style="margin-top:1px; margin-right:2px;")
          | 新 增

block thead
  tr
    th.center.aligned
    th.center.aligned 序 号
    th.center.aligned 创建时间
    th.center.aligned 消费商户
    th.center.aligned 消费终端
    th.center.aligned 代付商户
    th.center.aligned 代付终端
    th.center.aligned 代付渠道
    th.center.aligned 代付渠道商户
    th.center.aligned 消费手续费
    th.center.aligned 备 注

block tbody
  each record, index in records
    - var row_class = ''
    - var icon_class = ''
    - var icon_tip = ''
    - var icon_href = ''

    if (!record.checked)
      if (record.inputer == userinfo.uuid)
        - row_class = 'positive'
        case record.check_data.action
          when 1
            - icon_class = 'plus green'
            - icon_tip = '您增加了此记录，尚未通过复核，您可以再次修改'
            - icon_href = "/p1/new/" + record.uuid
          when 2
            - icon_class = 'write blue'
            - icon_tip = '您修改了此记录，尚未通过复核，您可以再次修改'
            - icon_href = "/p1/edit/" + record.uuid
          when 3
            - icon_class = 'minus red'
            - icon_tip = '您删除了此记录，尚未通过复核'
            - icon_href = "/p1/delete/" + record.uuid
      else
        - row_class = 'warning'
        - icon_href = "/p1/check/" + record.uuid
        case record.check_data.action
          when 1
            - icon_class = 'checkmark box green'
            - icon_tip = "用户 '" + record.input_user + "' 增加了此记录，请复核"
          when 2
            - icon_class = 'checkmark box blue'
            - icon_tip = "用户 '" + record.input_user + "' 修改了此记录，请复核"
          when 3
            - icon_class = 'checkmark box red'
            - icon_tip = "用户 '" + record.input_user + "' 删除了此记录，请复核"

    tr(class="#{row_class}")
      td.center.aligned.collapsing
        if (!record.checked)
          i.icon.link(class="#{icon_class}"
            data-content="#{icon_tip}"
            data-variation="small very wide"
            onclick="window.location = '#{icon_href}'")

      td.left.aligned.collapsing
        i.icon.caret.right.link.detail.expand
        if record.checked
          if page_perms.edit
            a(href="/p1/edit/#{record.uuid}")= record.serial
          else
            = record.serial
        else
          = record.serial
      td.center.aligned.collapsing= record.ctime.format('YYYY-MM-DD HH:mm:ss')
      td.center.aligned.collapsing= record.t20_merno
      td.center.aligned.collapsing= record.t20_termid
      td.center.aligned.collapsing= record.tz0_merno
      td.center.aligned.collapsing= record.tz0_termid
      td.collapsing.center.aligned= constant.pay_chnls[record.pay_chnl]
      td.collapsing.center.aligned= record.pay_merno
      td.center.aligned.collapsing= record.t20_fee_name
      td= record.notes

    tr.detail(style="display: none;")
      td.right.aligned.warning(colspan="1") 详细信息
      td(colspan="11"
        style="padding-top:0px; padding-bottom:0px; padding-right:1px;")
        include detail
